package com.ksjourney;

import mars.game.core.Config;
import mars.game.core.Sprite;

public class Balloon extends Sprite
{
	
	public static final int ANIMATION_LENGTH = 5;
	
	public static final int COLOR_LENGTH = 5;
	
	public static final int LIFE = 1;
	
	public static final int BLUE = R.drawable.img_balloon_blue_0;
	public static final int ORANGE = R.drawable.img_balloon_orange_0;
	public static final int PINK = R.drawable.img_balloon_pink_0;
	public static final int PURPLE = R.drawable.img_balloon_purple_0;
	public static final int RED = R.drawable.img_balloon_red_0;
	
	public static final int[] BALLOON_COLOR =
	{ BLUE, ORANGE, PINK, PURPLE, RED };
	
	public static final int[] ANIMATION_NOMAL =
	{ 0 };
	
	public static final int[] ANIMATION_BREAK =
	{ 0, 1, 2 };
	
	public static final int[] ANIMATION_SELECT =
	{ 0, 3 };
	
	public static final int NOMAL = 0;
	
	public static final int BREAK = 1;
	
	public static final int SELECT = 2;
	
	public static final int DISAPPEAR = 3;
	
	private Balloon(int resId)
	{

		super(ANIMATION_LENGTH, resId);
		this.state = BREAK;
		
	}
	
	public static Balloon markBalloon()
	{

		int random = (int) (Math.random() * COLOR_LENGTH);
		int color = BALLOON_COLOR[random];
		Balloon balloon = new Balloon(color);
		int x = (int) (Math.random() * Config.SCREEN_WIDTH);
		int y = (int) (Math.random() * Config.SCREEN_HEIGHT);
		balloon.setPos(x, y);
		balloon.setSpeed(-10, -5);
		balloon.setLife(LIFE);

		return balloon;
	}
	
	
	
	@Override
	public void tick()
	{
		super.tick();
		switch (state)
		{
			case NOMAL:
				this.mAniIndex = ANIMATION_NOMAL [mCounts % ANIMATION_NOMAL.length];
				break;
			case BREAK:
				this.mAniIndex = ANIMATION_BREAK [mCounts % ANIMATION_BREAK.length];
				break;
			case SELECT:

				break;
			case DISAPPEAR:

				break;
			
			default:
				break;
		}
		
	}
	
	
	
}
